#!/usr/bin/env python
#!coding=utf-8

from sqlalchemy.ext.declarative import declarative_base

__all__='Base,BaseInit'.split(',')

Base=declarative_base()
class BaseInit(object):
   
    def __init__(self,*args,**kws):
        super(BaseInit,self).__init__(*args,**kws)
        _fds=list(self.__class__.__table__.columns.keys())
        self.__dict__.update(dict([(_fds[i],v) for i,v in enumerate(args)]))
        self.__dict__.update(kws)
        
    def __repr__(self):
        return '<%s(%s)>' % (self.__class__.__name__,[self.__dict__.get(n) for n in list(self.__class__.__table__.columns.keys())])
            
    def __getitem__(self,name):
        print(('name',name))
        return self.__dict__[name]

    def __setitem__(self,name,value):
        self.__setattr__(name,value)    